# coding:UTF-8
# ________________________
# Project_Name:pythonProject
# File_Name:Administrator
# Author:Administrator
# Date_Time:2022/4/24 11:07
# Description:
# ________________________
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains


def foo1():
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get('https://map.baidu.com/@11588878,3564790,13z')
    driver.find_element(By.CLASS_NAME,'close-btn').click()  #关闭登录窗口


    #点击鼠标右建
    # context_click(element = None):
    #参数:可以是一个元素,右键点击这个元素
    #没有参数:默认参数是None,右键点击鼠标当前位置(打开网页后的鼠标当前位置是坐标原点)
    ActionChains(driver).context_click().perform()
    time.sleep(3)

    #双击地图
    ActionChains(driver).double_click().perform()
    time.sleep(3)

    #按住左键不放(注释:通过人工拖动鼠标显示效果)
    ActionChains(driver).click_and_hold().perform()
    time.sleep(3)

    #根据距离移动鼠标
    ActionChains(driver).move_by_offset(500,500).perform()
    time.sleep(3)

    #释放鼠标
    ActionChains(driver).release().perform()
    time.sleep(3)

    #拖拽鼠标
    #参数:  element如果点击当前鼠标位置,传值为None
    #      xoffset:x轴移动距离
    #      youffset:y轴移动距离
    ActionChains(driver).drag_and_drop_by_offset(None,-500,-500).perform()
    time.sleep(3)

    #ActionChains可以将多个操作f构建成动作的链条依次执行
    ActionChains(driver).click_and_hold().pause(1).move_by_offset(600,600).pause(1).release().pause(1).perform()
    time.sleep(3)




    driver.quit()






if __name__ == '__main__':
    foo1()